﻿@model Sharp.Web.Models.UserIndexModel
@{
    var x = Html.X();
}
@(
 x.GridPanel()
                .TopBar(x.Toolbar().Items(
                        x.Button().Text("浏览").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Details") + "');"),
                            x.Button().Text("新增").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Create") + "',{ShowOnly:true});"),
                            x.Button().Text("修改").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Edit") + "');"),
                            x.Button().Text("删除").OnClientClick("App.Grid.OnModuleOperation(this,'" + Url.Action("Delete") + "',{IsAjax:true});"),
                        x.Button().Text("权限").DirectClickAction("ListForUser", "Permission")
                        .DirectEvents(de =>
                        {
                            de.Click.ExtraParams.Add(new Parameter("owner", "user"));
                            de.Click.ExtraParams.Add(new Parameter("userName", " this.up('grid').getSelectionModel().getSelection()[0].getData().UserName", ParameterMode.Raw));

                            de.Click.ExtraParams.Add(new Parameter("ownerId", "this.up('grid').getSelectionModel().getSelection()[0].getData().Id", ParameterMode.Raw));
                        })
                    ,
                    new ToolbarFill(),
                    x.TextField().Width(300).FieldLabel("搜索").LabelWidth(50)
                        .Triggers(
                            x.FieldTrigger().Icon(TriggerIcon.Clear).HideTrigger(true),
                            x.FieldTrigger().Icon(TriggerIcon.Search)
                        ).Data(new { field = "UserName" })
                            .Listeners(ls => { ls.TriggerClick.Fn = "App.Main.searchFieldTriggerClick"; })
                    ))
                    .Plugins(x.GridFilters())
                .Store(x.StoreForModel().RemoteFilter(true)
                        .Proxy(x.AjaxProxy().Url(Url.Action("GetPaged")).Post().Reader(x.JsonReader().RootProperty("data")))
                    .RemoteSort(true).RemotePaging(true).PageSize(25)
                    .SorterFor(Model, m => m.Id, Ext.Net.SortDirection.DESC))
                .SelectionModel(x.CheckboxSelectionModel().Mode(SelectionMode.Multi))
            .ColumnModel(
                x.RowNumbererColumn().Align(ColumnAlign.End).Width(60),
                x.ColumnFor(m => m.UserName).Filter(x.StringFilter()),
                x.ColumnFor(m => m.LastLoginIP).Filter(x.StringFilter()),
                x.ColumnFor(m => m.DateLastLogon),
                x.ColumnFor(m => m.DateRegistered),
                x.ColumnFor(m => m.Email),
                x.ColumnFor(m => m.IsLockedOut)
            )
            .BottomBar(x.PagingToolbar().ItemsFromPartial("~/Views/Shared/_PagingToolbarPartial.cshtml"))
            .EmptyText("无数据。")
            .View(Html.X().GridView().StripeRows(true).TrackOver(true))
                .Listeners(li => { li.ItemDblClick.Fn = "App.Grid.OnModuleGridItemDblClick"; })
)